package com.credit.mola.app.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.credit.mola.app.R
import com.credit.mola.lib_baseadapter.SikadwaRecyclerViewAdapter
import com.credit.mola.lib_baseadapter.SikadwaViewHolderHelper
import com.credit.mola.app.utils.gilde.ImageUtil
import org.json.JSONObject

/**
 * Sikadwa
 * @Author wwdeng
 * @CreateTime: 2024/4/19 12:02
 * @Annotation：贷款已绑定账户适配器
 */
class CreditAccountAdapter(recyclerView: RecyclerView?): SikadwaRecyclerViewAdapter<JSONObject>(recyclerView,R.layout.item_credit_account) {

    override fun setItemChildListener(helper: SikadwaViewHolderHelper, viewType: Int) {
    }

    override fun fillData(helper: SikadwaViewHolderHelper, position: Int, model: JSONObject) {
        helper.setText(R.id.textName,model.optString("name"))
        helper.setText(R.id.textMobile,model.optString("account"))

        val logoUrl = model.optString("logo","")
        val imgLogo = helper.getImageView(R.id.imgLogo)
        if (logoUrl.isEmpty()){
            imgLogo.visibility = View.GONE
        } else {
            imgLogo.visibility = View.VISIBLE
            ImageUtil.instance?.loadImageUrl(mContext,imgLogo,logoUrl,R.mipmap.img_holder)
        }
    }
}